home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Systemmonitors / RSys / RSysSrc.lha / RSysHandlerList.c < prev    next >
C/C++ Source or Header  |  1993-09-19  |  4KB  |  141 lines

  1. /*
  2. ***************************************************************************
  3. *
  4. * Datei:
  5. *      RSysHandlerList.c
  6. *
  7. * Inhalt:
  8. *
  9. *      --- Globale Routinen ---
  10. *
  11. *    void MakeHandlerList ( void );
  12. *
  13. *      --- Lokale  Routinen ---
  14. *
  15. *
  16. * Bemerkungen:
  17. *      Erzeugung einer Liste von Inputhandlern.
  18. *
  19. * Erstellungsdatum:
  20. *      07-Jul-93     Rolf Böhme
  21. *
  22. * Änderungen:
  23. *      07-Jul-93     Rolf Böhme      Erstellung
  24. *
  25. ***************************************************************************
  26. */
  27.  
  28. #include "RSys.h"
  29.  
  30.     /*
  31.      * MakeHandlerList() erzeugt eine Liste aller angemeldeten
  32.      * InputHandler im System. Dazu muß ein Dummy-Handler
  33.      * installiert werden und über diesen werden die anderen
  34.      * InputHandler gefunden. Es existiert keine (!) öffentliche
  35.      * Liste mit allen InputHandlern.
  36.      */
  37. void
  38. MakeHandlerList(void)
  39. {
  40.     int    count = 0,
  41.             i = 0;
  42.     struct MsgPort *InputDevPort = NULL;
  43.     struct IOStdReq *InputRequestBlock = NULL;
  44.     struct Interrupt HandlerStuff;
  45.     struct Node *LoopNode, *StartNode, *node;
  46.  
  47.     DPOS;
  48.  
  49.     if (InputDevPort = (struct MsgPort *)CreatePort((UBYTE *) "RSys-Check-Port", NULL))
  50.     {
  51.         if (InputRequestBlock = (struct IOStdReq *)CreateStdIO(InputDevPort))
  52.         {
  53.             if (!OpenDevice((UBYTE *) "input.device", 0, (struct IORequest *) InputRequestBlock, 0))
  54.             {
  55.                 HandlerStuff.is_Code          = NULL;
  56.                 HandlerStuff.is_Data          = NULL;
  57.                 HandlerStuff.is_Node.ln_Pri   = -127;
  58.                 HandlerStuff.is_Node.ln_Name  = "RSys-Check-Handler";
  59.  
  60.                 InputRequestBlock->io_Command = IND_ADDHANDLER;
  61.                 InputRequestBlock->io_Data    = (APTR) &HandlerStuff;
  62.  
  63.                 DoIO((struct IORequest *) InputRequestBlock);
  64.  
  65.                     /*
  66.                      * Da InputHandler über Interrupts gesteuert werden
  67.                      * ist hier zum Auslesen ein Disable()/Enable()-
  68.                      * Paar zu verwenden
  69.                      */
  70.                 Disable();
  71.  
  72.                 for (LoopNode = (struct Node *) & (HandlerStuff.is_Node);
  73.                       LoopNode && LoopNode->ln_Pred;
  74.                       LoopNode = LoopNode->ln_Pred) ;
  75.  
  76.                 StartNode = LoopNode->ln_Succ;
  77.  
  78.                 for (node = StartNode; node->ln_Succ; node = node->ln_Succ)
  79.                     if (node != (struct Node *) & (HandlerStuff.is_Node)) count++;
  80.  
  81.                 Enable();
  82.  
  83.                 countentries = count;
  84.  
  85.                 if(NOT(NoEntries()))
  86.                 {
  87.                     Entries = AllocScrollEntries(countentries);
  88.  
  89.                     Disable();
  90.  
  91.                     for (LoopNode = (struct Node *) & (HandlerStuff.is_Node);
  92.                           LoopNode && LoopNode->ln_Pred;
  93.                           LoopNode = LoopNode->ln_Pred) ;
  94.  
  95.                     StartNode = LoopNode->ln_Succ;
  96.  
  97.                     for (node = StartNode; node->ln_Succ && (i < countentries);
  98.                           node = node->ln_Succ)
  99.                         if (node != (struct Node *) & (HandlerStuff.is_Node))
  100.                         {
  101.                             savestrcpy(Entries[i].se_obj_id.fullname, node, PARTSIZE, NT_INTERRUPT);
  102.                      Entries[i].se_obj_id.address = node;
  103.  
  104.                             sprintf(Entries[i].se_Entry,
  105.                                       EntryAttr[INPUTHDL].ea_dataformat,
  106.                              Entries[i].se_obj_id.address,
  107.                                       Entries[i].se_obj_id.fullname,
  108.                                       node->ln_Pri,
  109.                                       (long)((struct Interrupt *) node)->is_Data,
  110.                                       (long)((struct Interrupt *) node)->is_Code);
  111.  
  112.                             i++;
  113.                         }
  114.  
  115.                     countentries = i;
  116.  
  117.                     Enable();
  118.  
  119.                     CreateEntryList(SORT, 9);
  120.                 }
  121.  
  122.                 InputRequestBlock->io_Command = IND_REMHANDLER;
  123.                 InputRequestBlock->io_Data    = (APTR) & HandlerStuff;
  124.  
  125.                 DoIO((struct IORequest *) InputRequestBlock);
  126.  
  127.                 CloseDevice((struct IORequest *) InputRequestBlock);
  128.             }
  129.             else ErrorHandle("input.device", DEVICE_ERR, OPEN_FAIL, NO_KILL);
  130.  
  131.             DeleteStdIO(InputRequestBlock);
  132.         }
  133.         else ErrorHandle("CreateStdIO()", MISC_ERR, CREATE_FAIL, NO_KILL);
  134.  
  135.         DeletePort(InputDevPort);
  136.     }
  137.     else ErrorHandle("RSys-Check-Port", PORT_ERR, CREATE_FAIL, NO_KILL);
  138.  
  139.     return;
  140. }
  141.